import { getPatientBillingHistory } from '@/services/patient/patientApi';
import { showMsg } from '@/utils/utils';
import ProTable, { ProColumns } from '@ant-design/pro-table';

const DetailBillingHistory = (props: DetailProps) => {

  const { patient_id } = props;

  const columns: ProColumns[] = [
    {
      title: '结算编号',
      dataIndex: 'bill_id'
    },
    {
      title: '已出账金额',
      dataIndex: 'patient_id'
    },
    {
      title: '已结算金额',
      dataIndex: 'patient_name'
    },
    {
      title: '待结算金额',
      dataIndex: 'mobile'
    },
    {
      title: '责任人',
      dataIndex: 'available_integral'
    }
  ];

  return (
    <ProTable
      rowKey="bill_id"
      style={{ marginTop: 12, padding: '0 12px' }}
      options={false}
      bordered
      search={false}
      columns={columns}
      params={{ patient_id }}
      request={async (params) => {
        try {
          const res = await getPatientBillingHistory({ ...params });
          return { success: true, data: res.record_list, total: res.sum_record_num };
        } catch (reason: any) {
          showMsg(reason?.data?.errmsg);
          return { success: false, data: [] };
        }
      }}
      pagination={{ showQuickJumper: true }}
    />
  );
};

interface DetailProps {
  patient_id?: string;
}

export default DetailBillingHistory;
